import pytest
from selenium import webdriver
import os

#使用Pytest的Fixture特性设置测试环境
@pytest.fixture(scope='session')
def login():

    driver=None
    if os.getenv('webtype') == 'firefox':
        driver = webdriver.Firefox()
    elif os.getenv('webtype') == 'edge':
        driver = webdriver.Edge()

    elif os.getenv('webtype') == 'chrome':
        driver = webdriver.Chrome()

    #打开首页
    driver.get(os.getenv('url'))
    #窗口最大化
    driver.maximize_window()
    #隐式等待
    driver.implicitly_wait(8)
    #返回全部数据
    yield driver
    #退出登录
    driver.quit()
